package com.ttg.controller;

//~--- non-JDK imports --------------------------------------------------------

import com.ttg.contants.TestContants;
import com.ttg.contants.UrlContants;
import com.ttg.pojo.BindAndPayPojo;
import com.ttg.security.EncryptionUtils;
import com.ttg.utils.IdGenerator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

//~--- classes ----------------------------------------------------------------

/**
 * Class BindAndPayDemoController
 * Description
 * Create 2016-06-23 17:35:20
 * @author Ardy
 */
@Controller
@RequestMapping("/bind_and_pay")
public class BindAndPayDemoController {

    /**
     * Field logger
     * Description
     */
    private static final Logger logger = LoggerFactory.getLogger(BindAndPayDemoController.class);

    /**
     * Method testBindAndPay
     * Description 说明：
     *
     * @param model 说明：
     *
     * @return 返回值说明：
     */
    @RequestMapping
    public String testBindAndPay(Model model) {
        BindAndPayPojo bindAndPayPojo = new BindAndPayPojo();
        bindAndPayPojo.setUserId(TestContants.USER_ID);
        bindAndPayPojo.setAppId(TestContants.APP_ID);
        bindAndPayPojo.setMerchantId(TestContants.MERCHANT_ID);
        bindAndPayPojo.setMerOrderId(IdGenerator.genOrdId16());
        bindAndPayPojo.setTransAmt(0.01);
        bindAndPayPojo.setSignatureAlgorithm(TestContants.SIGNATUREALGORITHM);
        bindAndPayPojo.setBankId(TestContants.BANK_ID);
        bindAndPayPojo.setBgRetUrl("");
        bindAndPayPojo.setPageRetUrl("http://www.baidu.com");
        bindAndPayPojo.setCardType(TestContants.CARD_TYPE);
        bindAndPayPojo.setCardNo(TestContants.CARD_NO);

        bindAndPayPojo.setSignatureInfo(EncryptionUtils.encryption(bindAndPayPojo.getAllParameters()));

        model.addAttribute("bind_and_pay_url", UrlContants.BIND_AND_PAY_URL);
        model.addAttribute("bindAndPay",bindAndPayPojo);
        return "demo/bind_and_pay_demo";
    }
}


//~ Formatted by Jindent --- http://www.jindent.com
